import { S } from '../../s';
import { IPSAppDEUILogic } from '../dataentity/ipsapp-deuilogic';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSAppUILogic } from '../logic/ipsapp-uilogic';
import { IPSAppViewEngine } from './ipsapp-view-engine';
import { IPSAppViewLogic } from './ipsapp-view-logic';
import { IPSAppViewUIAction } from './ipsapp-view-uiaction';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppViewLogicImplBase
  extends PSModelObjectImpl
  implements IPSAppViewLogic
{
  get attrName(): string {
    return this.M.attrName;
  }

  get eventArg(): string {
    return this.M.eventArg;
  }

  get eventArg2(): string {
    return this.M.eventArg2;
  }

  get eventNames(): string {
    return this.M.eventNames;
  }

  get itemName(): string {
    return this.M.itemName;
  }

  get logicParam(): string {
    return this.M.logicParam;
  }

  get logicParam2(): string {
    return this.M.logicParam2;
  }

  get logicTrigger():
    | 'TIMER'
    | 'VIEWEVENT'
    | 'CTRLEVENT'
    | 'ITEMVISIBLE'
    | 'ITEMENABLE'
    | 'ITEMBLANK'
    | 'ITEMDYNACLASS'
    | 'RENDER'
    | 'ATTRIBUTE'
    | 'CUSTOM'
    | 'VUE_DIRECTIVE' {
    return this.M.logicTrigger;
  }

  get logicType():
    | 'APPDEUILOGIC'
    | 'APPDEUIACTION'
    | 'APPUILOGIC'
    | 'APPVIEWLOGIC'
    | 'APPVIEWENGINE'
    | 'PFPLUGIN'
    | 'SCRIPT'
    | 'DEUILOGIC'
    | 'DEUIACTION'
    | 'SYSVIEWLOGIC' {
    return this.M.logicType;
  }

  get owner(): IModel {
    return this.M.owner;
  }

  protected psappdeuilogic: IPSAppDEUILogic;
  getPSAppDEUILogic(): IPSAppDEUILogic | null {
    if (this.psappdeuilogic != null) return this.psappdeuilogic;
    const value = this.M.getPSAppDEUILogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdeuilogic = ipsappdataentity.findPSAppDEUILogic(value);
    }
    return this.psappdeuilogic;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psappuilogic: IPSAppUILogic;
  getPSAppUILogic(): IPSAppUILogic | null {
    return (
      this.psappuilogic ||
      (this.psappuilogic = this.fillObjectModel(
        S._280,
        this.M.getPSAppUILogic,
        S._2d7,
      ) as IPSAppUILogic)
    );
  }

  protected psappviewengine: IPSAppViewEngine;
  getPSAppViewEngine(): IPSAppViewEngine | null {
    return (
      this.psappviewengine ||
      (this.psappviewengine = this.fillObjectModel(
        S._296,
        this.M.getPSAppViewEngine,
        S._2d8,
      ) as IPSAppViewEngine)
    );
  }

  protected psappviewlogic: IPSAppViewLogic;
  getPSAppViewLogic(): IPSAppViewLogic | null {
    return (
      this.psappviewlogic ||
      (this.psappviewlogic = this.fillObjectModel(
        S._82,
        this.M.getPSAppViewLogic,
        S._2d9,
      ) as IPSAppViewLogic)
    );
  }

  protected psappviewuiaction: IPSAppViewUIAction;
  getPSAppViewUIAction(): IPSAppViewUIAction | null {
    return (
      this.psappviewuiaction ||
      (this.psappviewuiaction = this.fillObjectModel(
        S._8e,
        this.M.getPSAppViewUIAction,
        S._2da,
      ) as IPSAppViewUIAction)
    );
  }

  getPSViewCtrlName(): string {
    return this.M.getPSViewCtrlName;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }

  get builtinLogic(): boolean {
    return this.M.builtinLogic != null ? this.M.builtinLogic : true;
  }
  get cls(): string {
    return 'PSAppViewLogicImplBase';
  }
  instanceof(cls: string): boolean {
    if (cls == S._82) return true;
    return super.instanceof(cls);
  }
}
